export function getWeek(date) {
	var d = new Date(date);
	var weekday = ["日", "一", "二", "三", "四", "五", "六"];
	return weekday[d.getDay()]
}

export function formateDate(format,toDate) {
	//yyyt MM dd
	//当前时间
	toDate = new Date(toDate);
	var date = {
		"M+": toDate.getMonth() + 1,
		"d+": toDate.getDate(),
		"h+": toDate.getHours(),
		"m+": toDate.getMinutes(),
		"s+": toDate.getSeconds(),
		"q+": Math.floor((toDate.getMonth() + 3) / 3),
		"S+": toDate.getMilliseconds()
	};
	if(/(y+)/i.test(format)) {
		format = format.replace(RegExp.$1, (toDate.getFullYear() + '').substr(4 - RegExp.$1.length));
	}
	for(var k in date) {
		if(new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ?
				date[k] : ("00" + date[k]).substr(("" + date[k]).length));
		}
	}
	return format;
}
export function futureDay(date,num,formateInit){
	//获取未来几天后的时间
	var dateS = new Date(date).getTime()+86400*num;
	var formate = formateDate(formateInit,dateS);
	return formate;
}
export function futureAllDay(data,num,formateInit){
	//将未来几天的时间全部输出出去
	var dataArr = [];
	var datanum = new Date(data).getTime();
	for(let i=0;i<num;i++){
		var dateS = datanum + (86400000*i);
		dataArr[i] = {
			mouth:"",
			week:"",
		}
		var formate = formateDate(formateInit,dateS);
		var getweek =getWeek(dateS);
		dataArr[i].mouth=formate;
		dataArr[i].week=getweek;
	}
	return dataArr;
}
export function intervalTime(start,end){
	//获取两个日期之间的天数
	var s = new Date(formateDate("yyyy-MM-dd",new Date(start).getTime())).getTime();
	var e = new Date(formateDate("yyyy-MM-dd",new Date(end).getTime())).getTime();
	if(!s||!e){
		return "无";
	}
	if(s<e){
		var t = e-s;
	}else{
		var t = s-e;
	}
	return parseInt(t/86400000);
//	var dateS = new Date(date).getTime()+86400*num;
//	var formate = formateDate(formateInit,dateS);
//	return formate;
}
